const sharp = require('sharp');

const fs = require('fs');

const path = require('path');


const sourcePath = path.join('conan');
fs.existsSync(sourcePath)
if (!sourcePath) {
	console.error('folder "card" not exist');
}

fs.readdirSync(sourcePath).forEach(async file => {
	const image = path.join(sourcePath, file);
	const output = path.join('thumbnails', file);
	await sharp(image)
		.resize(200)
		.jpeg({ quality: 80 })
		.toBuffer().then(data => {
			fs.writeFileSync(output, data);
			console.log(output + ' : done');
		}).catch(err => console.log(err));
});

